/**
 * All Rights Reserved , Copyright (C) 2020 , 青岛鼎信通讯股份有限公司
 * <p>
 * PmInvoiceApplyController
 * 项目合同开票申请
 * <p>
 * 修改纪录
 * 2020-05-19 版本：1.0 wushenghong 创建。
 *
 * @version 版本：1.0
 * @author 作者：wushenghong
 * 创建日期：2020-05-19
 */

package com.topscomm.pm.controller;

import com.topscomm.basic.exception.MessageException;
import com.topscomm.basic.util.SQLAdapter;
import com.topscomm.cbo.pojo.CboAttachmentEntity;
import com.topscomm.cbo.service.impl.CboAttachmentService;
import com.topscomm.pm.PmSystemConst;
import com.topscomm.pm.PmSystemConst.InvoiceCancelStatusEnum;
import com.topscomm.pm.controller.auto.PmInvoiceApplyControllerAuto;
import com.topscomm.pm.pojo.PmInvoiceApplyEntity;
import com.topscomm.pm.pojo.PmInvoiceRecordEntity;
import com.topscomm.pm.pojo.PmProjectEntity;
import com.topscomm.pm.service.impl.PmCustomerBillService;
import com.topscomm.pm.service.impl.PmCustomerService;
import com.topscomm.pm.service.impl.PmInvoiceRecordService;
import com.topscomm.pm.service.impl.PmProjectService;
import com.topscomm.pm.utils.MisStringUtil;
import com.topscomm.pub.util.*;
import com.topscomm.pub.vo.Page;
import com.topscomm.pub.vo.Query;
import com.topscomm.pub.vo.ResponseResult;
import com.topscomm.tap.ITapService;
import com.topscomm.tap.common.ParameterCache;
import com.topscomm.tap.common.TapSystemConst;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author: wushenghong
 * @date: 2020-05-19
 * @description:项目合同开票申请Controller
 * @modify:
 */
@RestController
@RequestMapping("pm/invoiceApply")
public class PmInvoiceApplyController extends PmInvoiceApplyControllerAuto implements IPmInvoiceApplyController {
    @Resource
    private PmCustomerService pmCustomerService;
    @Resource
    private PmCustomerBillService pmCustomerBillService;
    @Resource
    private PmProjectService pmProjectService;
    @Resource
    private PmInvoiceRecordService pmInvoiceRecordService;
    @Autowired
    private CboAttachmentService cboAttachmentService;


    /**
     * @param paraMap
     * @return
     * @author: wushenghong
     * @date: 2020-05-19
     * @description:转换出查询SQL语句
     * @modify:
     */
    @Override
    protected String spellListSql(Map<String, Object> paraMap) {
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" PmInvoiceApply.enabled=1 ");
        if (paraMap.containsKey("qry_state")) {
            String value = paraMap.get("qry_state").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.state={0}", value);
        }
        if (paraMap.containsKey("qry_docno")) {
            String value = paraMap.get("qry_docno").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.docno like '%{0}%'", value);
        }

        if (paraMap.containsKey("qry_customername")) {
            String value = paraMap.get("qry_customername").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.customername like '%{0}%'", value);
        }

        if (paraMap.containsKey("qry_begindocdate")) {
            String value = paraMap.get("qry_begindocdate").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.docdate >= {0} ", SQLAdapter.toDateLong(value + " 00:00:00"));
        }
        if (paraMap.containsKey("qry_enddocdate")) {
            String value = paraMap.get("qry_enddocdate").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.docdate <= {0}", SQLAdapter.toDateLong(value + " 23:59:59"));
        }
        if (paraMap.containsKey("qry_deptname")) {
            String value = paraMap.get("qry_deptname").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and (PmInvoiceApply.deptid in ( SELECT id from CboDept where fullname like '%{0}%'))", value);
        }
        if (paraMap.containsKey("qry_username")) {
            String value = paraMap.get("qry_username").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and (PmInvoiceApply.sername like '%{0}%')", value);
        }
        if (paraMap.containsKey("qry_projectid")) {
            String value = paraMap.get("qry_projectid").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.projectid = {0} ", value);
        }
        if (paraMap.containsKey("qry_deptcode")) {
            String value = paraMap.get("qry_deptcode").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.deptcode like '{0}%'", value);
        }
        if (paraMap.containsKey("qry_state")) {
            String value = paraMap.get("qry_state").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.state={0}", value);
        }
        if (paraMap.containsKey("qry_where")) {
            String value = paraMap.get("qry_where").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and {0}", value);
        }
        // 查询可以申请作废的单据
        if (paraMap.containsKey("qry_isnotcancel")) {
            String value = paraMap.get("qry_isnotcancel").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.iscancel = {0} and PmInvoiceApply.category = '1'", value);
        }
        // 查询可以申请作废的单据
        if (paraMap.containsKey("qry_isnotcancel1")) {
            String value = paraMap.get("qry_isnotcancel1").toString();
            if ("0".equals(value)) {
                sql.appendSingle(" and (PmInvoiceApply.iscancel is null or PmInvoiceApply.iscancel='0') and PmInvoiceApply.category = '1'", value);
            }
        }
        if (paraMap.containsKey("qry_category")) {
            String value = paraMap.get("qry_category").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.category = '{0}'", value);
        }
        // 发票统计查询条件
        if (paraMap.containsKey("qry_customername")) {
            String value = paraMap.get("qry_customername").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and (PmInvoiceApply.customername like '%{0}%')", value);
        }
        if (paraMap.containsKey("qry_invoiceno")) {
            String value = paraMap.get("qry_invoiceno").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and (PmInvoiceApply.invoiceno like '%{0}%')", value);
        }
        if (paraMap.containsKey("qry_couriernumber")) {
            String value = paraMap.get("qry_couriernumber").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and (PmInvoiceApply.couriernumber like '%{0}%')", value);
        }
        if (paraMap.containsKey("qry_receiver")) {
            String value = paraMap.get("qry_receiver").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and (PmInvoiceApply.receiver like '%{0}%')", value);
        }
        if (paraMap.containsKey("qry_invoicedateStart")) {
            String value = paraMap.get("qry_invoicedateStart").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.invoicedate >= {0} ", SQLAdapter.toDateLong(value + " 00:00:00"));
        }
        if (paraMap.containsKey("qry_invoicedateEnd")) {
            String value = paraMap.get("qry_invoicedateEnd").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.invoicedate <= {0}", SQLAdapter.toDateLong(value + " 23:59:59"));
        }
        sql .appendSingle(this.spellingSqlForProject(paraMap, "PmInvoiceApply","projectid","id"));
        if (this.getUserBean().getUser().getAdminlevel() < 1)// 管理员、超级管理员，不控制权限
        {
            String dataPession = service.getDataPermission(TapSystemConst.TapOperationTypeEnum.Select, "", this.getUserBean());
            if (StringUtil.isEmpty(dataPession)) {
                sql.appendSingle(" and (" + MisStringUtil.createWhereByUsercodeFromProject(
                        this.getUserBean().getUser(), "projectid",
                        service.getDao().getTableName()) +
                                " or PmInvoiceApply.usercode = '{0}')",
                        this.getUserBean().getUser().getCode());
            } else// 使用数据权限
            {
                sql.appendSingle(" and {0} ", dataPession);
            }
        }
        return sql.toString();
    }

    //=========================发票开具查询相关====================================================================================================

    protected String spellListSqlStatistics(Map<String, Object> paraMap) {
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" PmInvoiceApply.enabled=1 ");
        if (paraMap.containsKey("qry_customername")) {
            String value = paraMap.get("qry_customername").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and (PmInvoiceApply.customername like '%{0}%')", value);
        }
        if (paraMap.containsKey("qry_invoiceno")) {
            String value = paraMap.get("qry_invoiceno").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and (PmInvoiceApply.invoiceno like '%{0}%')", value);
        }
        if (paraMap.containsKey("qry_couriernumber")) {
            String value = paraMap.get("qry_couriernumber").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and (PmInvoiceApply.couriernumber like '%{0}%')", value);
        }
        if (paraMap.containsKey("qry_receiver")) {
            String value = paraMap.get("qry_receiver").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and (PmInvoiceApply.receiver like '%{0}%')", value);
        }
        if (paraMap.containsKey("qry_invoicedateStart")) {
            String value = paraMap.get("qry_invoicedateStart").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.invoicedate >= {0} ", SQLAdapter.toDateLong(value + " 00:00:00"));
        }
        if (paraMap.containsKey("qry_invoicedateEnd")) {
            String value = paraMap.get("qry_invoicedateEnd").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.invoicedate <= {0}", SQLAdapter.toDateLong(value + " 23:59:59"));
        }
        if (paraMap.containsKey("qry_projectid")) {
            String value = paraMap.get("qry_projectid").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and PmInvoiceApply.projectid = {0}", value);
        }

        if (this.getUserBean().getUser().getAdminlevel() < 1)// 管理员、超级管理员，不控制权限
        {
            String dataPession = service.getDataPermission(TapSystemConst.TapOperationTypeEnum.Select, "", this.getUserBean());
            if (StringUtil.isEmpty(dataPession)) {
                sql.appendSingle(" and (" + MisStringUtil.createWhereByUsercodeFromProject(
                    this.getUserBean().getUser(), "projectid",
                    service.getDao().getTableName()) +
                        " or PmInvoiceApply.usercode = '{0}')",
                    this.getUserBean().getUser().getCode());
            } else// 使用数据权限
            {
                sql.appendSingle(" and {0} ", dataPession);
            }
        }

        return sql.toString();
    }

    @GetMapping({"/listStatistics"})
    public ResponseResult<Object> listStatistics(@RequestParam(required = false) Map<String, Object> paraMap) {
        try {
            paraMap = BaseUtil.decodeSecureMap(paraMap);
            Query query = new Query(paraMap);
            String sqlWhere = this.spellListSqlStatistics(paraMap);
            int totalCount = ((ITapService) this.service).getCount(sqlWhere);
            List<Map<String, Object>> tempList = null;
            if (query.getPageSize() > 0) {
                tempList = ((ITapService) this.service).queryMapForPage(sqlWhere, query.getCurrentPage(), query.getPageSize(), query.getSidx(), query.getSord());
            } else {
                tempList = ((ITapService) this.service).queryMapByWhere(sqlWhere);
            }

            ((ITapService) this.service).setDispFields(tempList);
            Page page = new Page(tempList, totalCount, query.getPageSize(), query.getCurrentPage());
            return ResponseResult.ok(page);
        } catch (Exception var7) {
            return this.handleControllerException(var7);
        }
    }
    //=========================发票开具查询相关结束====================================================================================================

    /**
     * @param paraMap
     * @return
     * @author: wushenghong
     * @date: 2020-05-19
     * @description:转换出查询SQL语句
     * @modify:
     */
    @Override
    @GetMapping(value = "/refList")
    public ResponseResult<Object> refList(@RequestParam(required = false) Map<String, Object> paraMap) {
        return super.refList(paraMap);
    }

    /**
     * @author: shenyouyi
     * @date: 2020-09-26
     * @param: paraMap
     * @return
     * @description: 根据Id获取申请信息
     * @modify:
     */
    @GetMapping(value = "/getInvoiceApplyById")
    public ResponseResult<Object> getInvoiceApplyById(@RequestParam(required = false) Map<String, Object> paraMap) {
        String id = paraMap.get("id").toString();
        PmInvoiceApplyEntity pmInvoiceApply = this.service.queryById(id);
        return ResponseResult.ok(pmInvoiceApply);
    }

    /**
     * @author: shenyouyi
     * @date: 2020-09-26
     * @param: paraMap
     * @return
     * @description: 发票系统回调函数
     * @modify:
     */
    @PostMapping("/invoiceCallback")
    public ResponseResult<Object> invoiceCallback(@RequestBody Map<String, Object> paraMap) throws Exception {
        this.service.invoiceCallback(paraMap);
        return ResponseResult.ok("操作成功");
    }

    /**
     * @param dataMap
     * @param paraMap
     * @throws Exception
     * @description: 提交审批前
     * @author: wushenghong
     * @date: 2020-05-19
     * @modify:
     */
    @Override
    protected void beforeSubmit(Map<String, Object> dataMap, Map<String, Object> paraMap) throws Exception {
        super.beforeSubmit(dataMap, paraMap);
        StringBufferProxy mailtitle = new StringBufferProxy();
        mailtitle.appendSingle("{0}{1}于{2}提交项目合同开票申请申请,单据编号{3}! ", dataMap.get("dispdeptcode"), dataMap.get("username"),
                DateUtil.dateToString(new Date(), "yyyy-MM-dd"), dataMap.get("docno"));
        dataMap.put("maintitle", mailtitle.toString());
        List<Map<String, Object>> flowidList = flowDatacodeCache.getApprovalFlowListMap("ApprovalFlow_PmBillApply", dataMap.get("deptcode").toString(), dataMap.get("usercode").toString(), null, "sortcode");
        Long flowid = flowidList.size() > 0 ? ConvertUtil.convertToLong(flowidList.get(0).get("id")) : null;
        dataMap.put("flowid", flowid);
    }

    // 取消审批
    @DeleteMapping({"/delApproval"})
    @Override
    public ResponseResult<Object> delApproval(@RequestBody(required = false) Map<String, Object> paraMap) {
        //拿到pminvoiceapply中的id，去pminvoicerecord中查看是否有记录，如果有记录，则不可以取消审批，报异常。弹出，“已开发票的单据无法取消审批”
        String id0 = ConvertUtil.convertToString(paraMap.get("id"));
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle("invoiceapplyid={0}",id0);
        List<PmInvoiceRecordEntity> pmInvoiceRecordEntities = pmInvoiceRecordService.queryByWhere(sql.toString());
        if(pmInvoiceRecordEntities!=null && pmInvoiceRecordEntities.size()>0){
            return ResponseResult.error("已开发票的单据无法取消审批");
        }
        ResponseResult responseResult = super.delApproval(paraMap);
        if (responseResult.isSuccess()) {
            String id = ConvertUtil.convertToString(paraMap.get("id"));
            this.service.updateBillMoneyOfProjectBase(id, false);
            return ResponseResult.ok("取消审批成功");
        }
        return responseResult;
    }

    @Override
    protected void afterLoad(Map<String, Object> paraMap) {
        super.afterLoad(paraMap);
        String projectId = ConvertUtil.convertToString(paraMap.get("projectid"));
        PmProjectEntity pmProjectEntity = pmProjectService.queryById(projectId);
        paraMap.put("projectcode", pmProjectEntity.getCode());
        paraMap.put("projectcontractmoney", pmProjectEntity.getContractmoney());
        paraMap.put("projectmoney", pmProjectEntity.getProjectmoney());
        paraMap.put("projectrecbillmoney", pmProjectEntity.getRecbillmoney());
        paraMap.put("projectbillmoney", pmProjectEntity.getBillmoney());
        // 添加可修改审批后单据信息的人员code系统参数
        paraMap.put("modifyInvoiceUserCode",ParameterCache.getValue("modifyInvoiceUserCode"));
    }

    /**
     * @author: shenyouyi
     * @date: 2020-09-29
     * @param: paraMap
     * @return
     * @description: 重写审批方法
     * @modify:
     */
    @PutMapping({"/approval"})
    public ResponseResult<Object> approval(@RequestBody(required = false) Map<String, Object> paraMap) {
        try {
            String approvalOpinion = paraMap.get("approvalopinion").toString();
            String approvalType = paraMap.get("approvaltype").toString();
            String nodeInsId = paraMap.get("nodeinsid").toString();
            String backNodeId = ConvertUtil.convertToString(paraMap.get("backnodeid"));
            long nextUserId = 0L;
            if (paraMap.containsKey("nextuserid") && !StringUtil.isEmpty(paraMap.get("nextuserid").toString())) {
                nextUserId = Long.parseLong(paraMap.get("nextuserid").toString());
            }
            if(!approvalType.equals(ConvertUtil.convertToString(TapSystemConst.TapApprovalFlowStateEnum.Approveing))){// 审批不通过
                String sourceid = ConvertUtil.convertToString(paraMap.get("sourceid"));
                PmInvoiceApplyEntity pmInvoiceApplyEntity = this.service.queryById(sourceid);
                if(!pmInvoiceApplyEntity.getCategory().equals(PmSystemConst.DocTypeEnum.New)){// 如果节点有审批不通过，则把原发票置为有效状态
                    pmInvoiceRecordService.setInvoiceState(pmInvoiceApplyEntity.getOldid(), pmInvoiceApplyEntity.getOldinvoicecode(), PmSystemConst.InvoiceCancelStatusEnum.Enabled);
                }
            }
            ((ITapService)this.service).executeApprove(nodeInsId, new Date(), approvalOpinion, approvalType, backNodeId, this.getUserBean(), nextUserId);
            return ResponseResult.ok("操作成功");
        } catch (Exception var8) {
            return this.handleControllerException(var8);
        }
    }
    /**
     * @author: liwanpeng
     * @date: 2020-11-17
     * @param: paraMap
     * @return
     * @description: 强制修改，修改审批后的单据内容
     * @modify:
     */
    @PostMapping({"/modifyDoc"})
    public ResponseResult<Object> modifyDoc(@RequestBody(required = false) Map<String, Object> paraMap) {
        try {
            // 获取需要修改的单据的id
            String id = ConvertUtil.convertToString(paraMap.get("id"));
            // 获取需要修改的字段（key）
            List<String> listFielsQuery = new ArrayList<>(paraMap.keySet());
            // 查询原有单据信息
            PmInvoiceApplyEntity pmInvoiceApplyEntity = this.service.queryById(id);
            // 组装修改记录
            String s = MisStringUtil.generateModifyRecordJsonStr(this.getUserBean().getUser(), pmInvoiceApplyEntity, paraMap);
            // 更新相关字段
            paraMap.put("modifyrecord",s);
            this.service.update(paraMap);
            return ResponseResult.ok("操作成功");
        } catch (Exception var8) {
            return this.handleControllerException(var8);
        }
    }

    /**
     * @author: wudaliang
     * @date: 2021-02-20
     * @param: dataMap
     * @param: paraMap
     * @description: 税率为3%或者9%的发票，进行备注内容设置
     * @return: void
     * @modify:
     */
    @Override
    protected void beforeInsert(Map<String, Object> dataMap, Map<String, Object> paraMap) throws Exception {
        super.beforeInsert(dataMap, paraMap);
        String invoicetype = paraMap.get("invoicetype").toString();
        if ("9".equals(invoicetype) || "10".equals(invoicetype) || "17".equals(invoicetype) || "18".equals(invoicetype)) {
            if(paraMap.get("description")==null||!paraMap.get("description").toString().contains("项目名称")||!paraMap.get("description").toString().contains("项目地点")
                ||paraMap.get("description").toString().length()<=8||!paraMap.get("description").toString().contains("\n")){
                throw new MessageException("发票类型为税率是3%或者9%的发票，必须在发票备注里按照格式写明项目名称和项目地点");
            }
        }
    }

    @Override
    @GetMapping({"/list"})
    public ResponseResult<Object> list(@RequestParam(required = false) Map<String, Object> paraMap) {
        try {
            paraMap = BaseUtil.decodeSecureMap(paraMap);
            Query query = new Query(paraMap);
            String sqlWhere = this.spellListSql(paraMap);
            paraMap.put("whereSql",sqlWhere);
            int totalCount = this.service.getCount(paraMap,"getInvoiceAndProjectCount");
            List<Map<String, Object>> tempList = null;
            HashMap<String, Object> paraMap2 = new HashMap<>();
            paraMap2.put("curPageIndex",query.getCurrentPage());
            int beginCount=query.getCurrentPage()*query.getPageSize()-query.getPageSize();
            paraMap2.put("begincount",beginCount);
            paraMap2.put("pagesize", query.getPageSize());
            paraMap2.put("sidx", query.getSidx());
            paraMap2.put("sord", query.getSord());
            paraMap2.put("whereSql", sqlWhere);
            if (query.getPageSize() > 0) {
                tempList = this.service.queryMapForPage(paraMap2,"getInvoiceAndProject");
            } else {
                tempList = this.service.queryMap(paraMap2,"queryMapByWhere1");
            }
            this.service.setDispFields(tempList);
            Page page = new Page(tempList, totalCount, query.getPageSize(), query.getCurrentPage());
            return ResponseResult.ok(page);
        } catch (Exception var7) {
            return this.handleControllerException(var7);
        }
    }


    @Override
    @GetMapping({"/load"})
    public ResponseResult<Object> load(@RequestParam(required = false)Map<String, Object> paraMap) {
        try {
            paraMap = BaseUtil.decodeSecureMap(paraMap);
            Map<String, Object> dataMap = this.service.queryMapById(paraMap.get("id").toString());
            this.afterLoad(dataMap);
            StringBufferProxy sql = new StringBufferProxy();
            sql.appendSingle(" SOURCEID='{0}' and SOURCETYPE='PmInvoiceApply' ",paraMap.get("id"));
            List<CboAttachmentEntity> cboAttachmentEntities = cboAttachmentService
                .queryByWhere(sql.toString());
            dataMap.put("cboattachmentcount",cboAttachmentEntities.size());
            return ResponseResult.ok(dataMap);
        } catch (Exception var3) {
            return this.handleControllerException(var3);
        }

    }

    /**
     * 重写手机端审批信息接口
     */
//    @GetMapping(value = "/loadMobilePageInfo")
//    @Override
//    public ResponseResult<Object> loadMobilePageInfo(@RequestParam(required = false) Map<String, Object> paraMap)
//            throws SQLException, IOException {
//        paraMap = BaseUtil.decodeSecureMap(paraMap);
//        String pageCode = this.service.getDao().getTableName();
//        Map<String, Object> myDadaMap = new HashMap<>();
//        StringBufferProxy sqlForAppPage = new StringBufferProxy();
//        StringBufferProxy sqlForAppPageTab = new StringBufferProxy();
//        sqlForAppPage.appendSingle("code='{0}' and enabled=1", pageCode);
//        AppPageEntity page = appPageService.queryObjectByWhere(sqlForAppPage.toString());
//        sqlForAppPageTab.appendSingle("pageid='{0}' and enabled=1", page.getId());
//        // 开票申请单据的ID
//        Map<String, Object> mainListData = this.service.queryMapById(paraMap.get("id").toString());
//        List<Map<String, Object>> mainList = new ArrayList<>();
//        mainList.add(mainListData);
//        myDadaMap.put("mainList", mainList);
//        // 查询关联的客户档案
//        Map<String, Object> customerMap = pmCustomerService
//                .queryMapById(ConvertUtil.convertToString(mainListData.get("customerid")));
//        List<Map<String, Object>> listCustomer = new ArrayList<>();
//        listCustomer.add(customerMap);
//        myDadaMap.put("pmCustomer", listCustomer);
//        // 查询此客户关联的客户开票档案
//        StringBufferProxy sqlForCustomerBill = new StringBufferProxy();
//        sqlForCustomerBill.appendSingle("customerid='{0}'", ConvertUtil.convertToString(customerMap.get("id")));
//        List<Map<String, Object>> customerBillMapList = pmCustomerBillService
//                .queryMapByWhere(sqlForCustomerBill.toString());
//        myDadaMap.put("customerBillInfo", customerBillMapList);
//        appPageService.getPageInfo(pageCode, myDadaMap);
//        return ResponseResult.ok(myDadaMap);
//    }
}
